﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class admin_manageAdmin : System.Web.UI.Page
{
    Admin a = new Admin();

    protected void Page_Load(object sender, EventArgs e)
    {
        Function.CheckSession();
        if (!this.IsPostBack)
        {
            Bind();
        }
    }

    void Bind()
    {
        this.GridView1.DataSource = a.GetAllAdmin();
        this.GridView1.DataBind();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        a.Adminname = this.TextBox1.Text.Trim();
        a.Adminpwd = Function.ReturnMd5Pwd(this.TextBox3.Text.Trim());
        a.AddAdmin(a);
        Response.Write("<script>alert('添加成功');location.href('manageAdmin.aspx');</script>");
    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        a.DelAdmin(int.Parse(this.GridView1.DataKeys[e.RowIndex].Value.ToString()));
        Bind();
    }
}
